@extends('Home.Index.index')
@section('title')
    购物车
@endsection
@section('content')
    <section id="main" class="entire_width">
        <div class="container_12">
            <div class="grid_12">
                <h1 class="page_title">购物车</h1>
                <table class="cart_product">
                    <tr>
                        <th class="images"></th>
                        <th class="bg name">商品名称</th>
                        <th class="qty">商品数量</th>
                        <th class="close">单价</th>
                        <th class="bg price">商品总价</th>
                        <th class="bg subtotal">删除</th>
                    </tr>
                    {{--这里写购物车列表--}}
                    @if(empty($user_info))
                            @if(empty($add_shopping_cart))
                                @else
                            @foreach($add_shopping_cart as $v)
                                <tr>
                                    {{--购物车商品图片和商品详情--}}
                                    <td class="images"><a href=""><img src="{{$v['img_src']}}" alt=""></a></td>
                                    <td class="bg name">{{$v['goods_name']}}</td>
                                    <td class="qty"><input type="text" name="" value="" placeholder="{{$v['goods_count']}}"/></td>
                                    <td class="close">￥{{$v['price']}}</td>
                                    <td class="bg price">￥{{$v['price']*$v['goods_count']}}</td>
                                    <td class="bg subtotal"><a title="close" class="close" onclick="class_del(this,'{{$v['goods_id']}}')" ></a></td>
                                </tr>
                            @endforeach
                                @endif
                        @else
                        @foreach($goods_list as $list)
                            <tr>
                                {{--购物车商品图片和商品详情--}}
                                <td class="images"><a href=""><img src="{{$list->img_src}}" alt=""></a></td>

                                @if(empty($list->property))
                                    <td class="bg name">{{$list->goods_name}}</td>
                                    @else
                                    <td class="bg name">{{$list->goods_name}}&nbsp;<br>{{$list->property}}</td>
                                    @endif

                                <td class="qty"><input type="text" name="" value="" placeholder="{{$list->goods_count}}"/></td>
                                <td class="close">￥{{$list->price}}</td>
                                <td class="bg price">￥{{$list->price*$list->goods_count}}</td>
                                <td class="bg subtotal"><a title="close" class="close" onclick="class_del(this,'{{$list->goods_id}}')" ></a></td>
                            </tr>
                        @endforeach
                        @endif
                    <tr>
                        <td colspan="7" class="cart_but">
                            <button class="continue"><a href="{{url('home_index')}}">继续购物</a></button>
                            <button class="update"><a href="{{url('goods_pay')}}">立即结算</a></button>
                        </td>
                    </tr>
                </table>
            </div><!-- .grid_12 -->
        </div><!-- .container_12 -->
    </section><!-- #main -->
    <div class="clear"></div>
    <script>
        function class_del(obj,goods_id) {
            layer.confirm('确认要删除该商品吗？', function (index) {
                $.ajax({
                    type: 'POST',
                    url: '/goods_delete/'+goods_id,
                    dataType: 'json',
                    success: function (e) {
                        if (e.status) {
                            $(obj).parents("tr").remove();
                            layer.msg('删除成功!', {icon: 1, time: 1000});
                        }else {
                            layer.msg(e.info);
                        }
                    }
                });
            });
        }
    </script>
@endsection